﻿<?php
    $dom = new DomDocument;
    $dom->load("books.xml");
    
    foreach($dom->documentElement->childNodes as $books){
        if(($books->nodeType == 1) && ($books->nodeName == "book")){
            foreach($books->childNodes as $thebook){
                if(($thebook->nodeType ==1)&&($thebook->nodeName == "title.a")){
                    $theBookTitle = $thebook->textContent;
                }
                if(($thebook->nodeType ==1)&&($thebook->nodeName == "title.b")){
                    $theBookTitleb = $thebook->textContent;
                }
                if(($thebook->nodeType ==1)&&($thebook->nodeName == "author")){
                    $theBookAuthor = $thebook->textContent;
                }
                
            }
            echo  "책이름a : " .$theBookTitle ."<br>"." 책이름b : " .$theBookTitleb ."<br>"."책 작가:". $theBookAuthor."<br><br>";
            unset($theBookTitle);            
            unset($theBookTitleb);
            unset($theBookAuthor);
        }
    }
    
?>